<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="https://unpkg.com/vue"></script>

    <script>
        window.onload=function(){
            // 注册
            Vue.component('my-component', {
                template: '<div>A custom component!</div>'
            })
// 创建根实例
            new Vue({
                el: '#example'
            })

            var Child = {
                template: '<button v-on:click="counter += 1">{{ counter }}</button>',
                data: function () {
                    return {
                        counter: 0
                    }
                }
            }
            new Vue({
                // ...
                el: '#example-2',
                components: {
                    // <my-component> 将只在父模板可用
                    'simple-counter': Child
                }

            })
            Vue.component('child', {
                // camelCase in JavaScript
                props: ['myMessage'],
                template: '<span>{{ myMessage }}</span>'
            })
            new Vue({
                el: '#example3',
                data:{
                    parentMsg:''
                }
            })
        }
    </script>
</head>
<body>
<div id="example">
    <my-component></my-component>
</div>
<div id="example-2">
    <simple-counter></simple-counter>
    <simple-counter></simple-counter>
    <simple-counter></simple-counter>
</div>
<div id="example3">
    <input v-model="parentMsg">
    <br>
    <child v-bind:my-message="parentMsg"></child>
</div>
</body>
</html>